Completed
Push — master ( ca354f...7077f3 )
by Michal
09:04
created

gruntfile.js ➔ ???   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 79

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 79
rs 8.8701
c 1
b 0
f 0
cc 1
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
module.exports = (grunt) => {
2
  // Config
3
  const config = {
4
    publicDir: 'www',
5
    buildDir: 'dist',
6
    manifest: 'manifest.json',
7
  };
8
9
  require('load-grunt-tasks')(grunt);
10
  grunt.initConfig({
11
    // JS
12
    babel: {
13
      options: {
14
        presets: ['es2015'],
15
        sourceMap: true,
16
      },
17
      dist: {
18
        files: {
19
          [`${config.publicDir}/${config.buildDir}/js/app.js`]: 'www/data/scripts/index.js',
20
        }
21
      }
22
    },
23
    // SASS
24
    sass: {
25
      options: {
26
        sourceMap: true
27
      },
28
      dist: {
29
        files: {
30
          [`${config.publicDir}/${config.buildDir}/css/app.css`]: 'www/data/styles/main.scss',
31
        }
32
      }
33
    },
34
    // Revision manifest
35
    filerev: {
36
      options: {
37
        algorithm: 'md5',
38
        length: 8
39
      },
40
      scripts: {
41
        files: [{
42
          src: [
43
            `${config.publicDir}/${config.buildDir}/**/*.js`,
44
          ]
45
        }]
46
      },
47
      styles: {
48
        files: [{
49
          src: [
50
            `${config.publicDir}/${config.buildDir}/**/*.css`,
51
          ]
52
        }]
53
      },
54
    },
55
    filerev_assets: {
56
      dist: {
57
        options: {
58
          dest: `${config.publicDir}/${config.buildDir}/${config.manifest}`,
59
          cwd: `${config.publicDir}/`,
60
          prettyPrint: true,
61
        }
62
      }
63
    },
64
    // Clean
65
    clean: {
66
      manifest: [`${config.publicDir}/${config.buildDir}/manifest.json`],
67
      scripts:  [`${config.publicDir}/${config.buildDir}/js`],
68
      styles:   [`${config.publicDir}/${config.buildDir}/css`],
69
    },
70
  });
71
72
73
  grunt.loadNpmTasks('grunt-filerev');
74
  grunt.loadNpmTasks('grunt-filerev-assets');
75
76
  grunt.registerTask('scripts', ['clean:scripts', 'babel', 'filerev:scripts', 'filerev_assets']);
77
  grunt.registerTask('styles',  ['clean:styles',  'sass',  'filerev:styles',  'filerev_assets']);
78
  grunt.registerTask('default', ['styles', 'scripts']);
79
};
80